<?php use_helper('I18N'); ?>
<style type="text/css">
    p img {
        background: none repeat scroll 0 0 white;
        border: 1px solid #BBBBBB;
        margin: 7px 14px 7px 0;
        padding: 5px;
        height: 50px;
        /*width: 160px;*/
    }
</style>

<script type="text/javascript">
$(function() {
    var container = $('div.errorContainer');
    $("#addressBookForm").validate({
                errorLabelContainer: $("ol", container),
                errorContainer: $('div.errorContainer'),
                wrapper: 'li',
                meta: "validate",
                messages : {
                    address1: {
                        required: "<?php echo __('%1% is required.', array('%1%' => 'Address')) ?>"
                    },
                    city: {
                        required: "<?php echo __('%1% is required.', array('%1%' => 'City')) ?>"
                    },
                    state: {
                        required: "<?php echo __('%1% is required.', array('%1%' => 'State')) ?>"
                    },
                    postcode: {
                        required: "<?php echo __('%1% is required.', array('%1%' => 'Postcode')) ?>"
                    },
                    country: {
                        required: "<?php echo __('%1% is required.', array('%1%' => 'Country')) ?>"
                    }
                },
                rules : {
                    "address1" : {
                        required : true,
                        minlength : 10
                    },
                    "city" : {
                        required : true
                    },
                    "state" : {
                        required : true
                    },
                    "postcode" : {
                        required : true,
                        minlength : 3
                    },
                    "country" : {
                        required : true
                    }
                },
                submitHandler: function(form) {
                    form.submit();
                }
            });
    $("#validate-close").click(function() {
        $(container).hide(500);
    });
    $("#btnBack").button({
        icons: {
            primary: "ui-icon-circle-arrow-w"
        }
    });
    $("#btnUpdate").button({
        icons: {
            primary: "ui-icon-circle-check"
        }
    }).click(function(){
        $("#frmAccountPassword").submit();
    });
});
</script>

<div style="z-index: 999; position: fixed; top:0px; right:0px;"
     class="errorContainer ui-state-error-validate ui-corner-all container ui-widget" id="validateContainer">
    <p>
        <span style="float: left; margin-right: .3em;" class="ui-red ui-icon ui-icon-alert"></span>
        <a href="#" id="validate-close" role="button" class="ui-dialog-titlebar-close ui-corner-all">
            <span style="position:absolute; right : -2px; margin-right: .3em; border: 1px solid #FBCB09; color: #C77405;"
                  class="ui-icon ui-icon-closethick"></span>
        </a>
        <strong id='_msg'>
            <ol style="padding-top:0px;margin-top:0px;margin-bottom:0px"></ol>
        </strong>
    </p>
</div>

<div id="content">

    <!-- ========== CATEGORIES TABS ========= -->
    <!-- ==================================== -->
    <table id="contentMainWrapper" border="0" cellpadding="0" cellspacing="0" width="100%">
        <tbody>
        <tr>
            <td id="column-left" style="width: 215px;">
                <div style="width:215px;">
                    <!--// bof: categories //-->
                    <div class="box" id="categories" style="width:215px;">
                        <div class="box-border">
                            <div class="box-head">
                                <?php echo __('Categories') ?>
                            </div>
                            <div class="box-body">
                                <?php include_component('component', 'categoriesSideMenu') ?>
                            </div>
                        </div>
                    </div>
                    <!--// eof: categories //-->
                    <!--// bof: specials //-->
                    <div class="box" id="specials" style="width:215px;">
                        <div class="box-border">
                            <div class="box-head">
                                <a href="<?php echo url_for("/product/specialItem") ?>"><?php echo __('Specials') ?></a>
                            </div>
                            <div class="box-body">
                                <?php include_component('component', 'specialsSideMenu', array('param' => 'will implement for categoryType')) ?>
                            </div>

                        </div>
                    </div>
                    <!--// eof: specials //-->
                </div>
            </td>
            <td id="column-center" valign="top">
                <!-- BOF- BANNER #3 display -->
                <!-- EOF- BANNER #3 display -->
                <div class="column-center-padding">
                    <!--content_center-->
                    <!-- bof breadcrumb -->
                    <!-- eof breadcrumb -->

                    <!-- bof upload alerts -->
                    <!-- eof upload alerts -->
                    <div class="centerColumn" id="accountEditDefault">
                        <form name="addressBookForm" action="/member/updateAddressBook" method="post">
                            <input type="hidden" id="addressId" name="addressId" value="<?php echo $address->getAddressId()?>">
                            <?php if ($sf_flash->has('errorMsgLogin')): ?>
                                <?php echo $sf_flash->get('errorMsgLogin') ?>
                            <?php endif; ?>
                                <h1 id="accountDefaultHeading"><?php echo $title; ?></h1>

                                <fieldset>
                                    <legend><?php echo __('Address Details') ?></legend>
                                    <label class="inputLabel" for="street-address">Street Address <span class="alert">*</span>:</label>
                                    <input name="address1" size="41" maxlength="64" id="street-address" type="text" value="<?php echo $address->getAddress1()?>">
                                    <br class="clearBoth">

                                    <label class="inputLabel" for="suburb">Address Line 2:</label>
                                    <input name="address2" size="33" maxlength="32" id="suburb" type="text" value="<?php echo $address->getAddress2()?>">
                                    <br class="clearBoth">

                                    <label class="inputLabel" for="city">City <span class="alert">*</span>:</label>
                                    <input name="city" size="33" maxlength="32" id="city" type="text" value="<?php echo $address->getCity()?>">
                                    <br class="clearBoth">

                                    <label class="inputLabel" for="state" id="stateLabel">State/Province <span class="alert" id="stText">*</span>:</label>
                                    <input name="state" size="33" maxlength="32" id="state" type="text" value="<?php echo $address->getState()?>">
                                    <br class="clearBoth">

                                    <label class="inputLabel" for="postcode">Post/Zip Code <span class="alert">*</span>:</label>
                                    <input name="postcode" size="11" maxlength="10" id="postcode" type="text" value="<?php echo $address->getPostcode()?>">
                                    <br class="clearBoth">

                                    <label class="inputLabel" for="country">Country <span class="alert">*</span>:</label>
                                    <?php include_component('component', 'countrySelectOption', array('countrySelected' => $address->getCountry(), 'countryName' => 'country', 'countryId' => 'country')) ?>
                                    <br class="clearBoth">
                                </fieldset>

                                <div class="buttonRow forward">
                                    <button id="btnUpdate"><?php echo __('Update') ?></button>
                                </div>
                                <div class="buttonRow back">
                                    <a id="btnBack" href="<?php echo url_for("/member/myAccount");?>"><?php echo __('Back') ?></a>
                                </div>
                            <br class="clearBoth">

                        </form>
                    </div>
                    <div class="clear"></div>
                    <!--eof content_center-->
                </div>
                <!-- BOF- BANNER #4 display -->
                <!-- EOF- BANNER #4 display -->
            </td>
        </tr>
        </tbody>
    </table>
</div>